﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;

namespace PTViewer
{
    class Helper
    {
        public const string FORUMS_LIST_URL = "http://www.sql.ru/forum/actualforum.aspx";

        string userAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2";
        string Referer = "http://www.sql.ru/forum/actualtopics.aspx?bid=16";

        public string DownloadWebPage(string Url)
        {
            var req = (HttpWebRequest)WebRequest.Create(Url);
            req.UserAgent = userAgent;
            req.Referer = Referer;
            var response = req.GetResponse();
            Stream responseStream = response.GetResponseStream();
            StreamReader streamReader = new StreamReader(responseStream, Encoding.GetEncoding("windows-1251"));
            string result = streamReader.ReadToEnd();
            streamReader.Close();
            responseStream.Close();
            response.Close();
            return result;
        }
    }
}
